//
//  HMComposeButton.swift
//  WB25
//
//  Created by HM on 2017/7/7.
//  Copyright © 2017年 itheima. All rights reserved.
//

import UIKit

class HMComposeButton: UIButton {
    
    // 使用属性方便
    var composeModel: HMComposeModel?
    
    // 干掉高亮的效果
    override var isHighlighted: Bool{
        get{
            return false
        }
        
        set{
           // 空实现
        }
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //MARK: - 设置视图
    private func setupUI(){
//        backgroundColor = randomColor()
        imageView?.contentMode = .center
        
        titleLabel?.textAlignment = .center
        titleLabel?.font = UIFont.systemFont(ofSize: HMNormalFontSize)
        setTitleColor(UIColor.darkGray, for: UIControlState.normal)
    }
    
    //MARK: - 重写
    override func layoutSubviews() {
        super.layoutSubviews()
        // imageView
        imageView?.frame = CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.width)
        // titleLabel
        titleLabel?.frame = CGRect(x: 0, y: self.frame.width, width: self.frame.width, height: self.frame.height - self.frame.width)
    }

}
